Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code scanning alert no. 35: Multiplication result converted to larger type #26

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

cooljeanius
Copy link
Owner

Fixes https://github.com/cooljeanius/emacs/security/code-scanning/35

To fix the problem, we need to ensure that the multiplication is performed using the larger type to prevent overflow. This can be done by casting one of the operands to ptrdiff_t before performing the multiplication. This way, the multiplication will be done in the larger type, and the result will be correct.

The best way to fix this without changing existing functionality is to cast ccl.produced to ptrdiff_t before the multiplication. This change should be made on line 2161 of the file src/ccl.c.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…rger type

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@cooljeanius cooljeanius marked this pull request as ready for review September 26, 2024 12:41
Copy link
Owner Author

@cooljeanius cooljeanius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a simple cast; ok

@cooljeanius cooljeanius merged commit 013e7d2 into master Sep 26, 2024
19 checks passed
@cooljeanius cooljeanius deleted the autofix/alert-35-d6fbb9cf75 branch September 26, 2024 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant